﻿using System.Xml;
using NJabber.Stream.Elements;

namespace NJabber.Stream.Elements
{
    internal class XmppStreamElementImpl : XmppStreamElement
    {
        public XmppStreamElementImpl(string name)
            : base(name)
        {
        }

        public XmppStreamElementImpl(string name, string namespaceName)
            :base(name, namespaceName)
        {
        }

        public XmppStreamElementImpl(string name, string namespaceUri, string namespaceName)
            : base(name, namespaceUri, namespaceName)
        {
        }

        public string Content { get; set; }

        public object this[string name, string nsName="", string nsUri=""]
        {
            get
            {
                return GetAttributeValue(nsName, name, nsUri);
            }
            set
            {
                SetAttributeValue(nsName, name, nsUri, value);
            }
        }

        protected override void WritePayload(XmlWriter writer)
        {
            if (!string.IsNullOrEmpty(Content)) writer.WriteString(Content);
        }
    }
}
